﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using RDPAddins.Common;

namespace RDPAddins
{
    internal partial class SlaveMode : Form
    {
        public RDPClient Client;

        public SlaveMode()
        {
            InitializeComponent();
        }

        public SlaveMode(RDPClient Client)
        {
            this.Client = Client;
            InitializeComponent();
        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!RealClosing)
            {
                e.Cancel = true;
                Visible = false;
            }
        }

        public bool RealClosing { get; internal set; }

        public void ShowMe(object sender, EventArgs e)
        {
            Visible = !Visible;
        }

        public delegate void Void();


        private void frmMain_VisibleChanged(object sender, EventArgs e)
        {
             mnuNICHide.Visible = Visible;
             mnuNICShow.Visible = !Visible;
        }

        Channel lastaddin = null;

        public int AddImage(Image image)
        {
            if (image == null)
                return 0;
            ilMain.Images.Add(image);
            return ilMain.Images.Count - 1;
        }

        public void ShowToolTip(int timeout, string tipTitle, string tipText, ToolTipIcon tipIcon, Channel addin)
        {
            lastaddin = addin;
            niMain.ShowBalloonTip(timeout, tipTitle, tipText, tipIcon);
        }

        private void mnuAbout_Click(object sender, EventArgs e)
        {
            (new frmAbout()).ShowDialog(this);
        }

        private void niMain_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ShowMe(null, null);
        }

        public override string Text
        {
            get
            {
                return base.Text;
            }
            set
            {
                base.Text = value;
                niMain.Text = value;
            }
        }


        private void frmMain_Activated(object sender, EventArgs e)
        {
            Bounds = new System.Drawing.Rectangle(Screen.PrimaryScreen.WorkingArea.Right - Width, Screen.PrimaryScreen.WorkingArea.Bottom - Height, Width, Height);
        }

        private void niMain_BalloonTipClicked(object sender, EventArgs e)
        {
            if (lastaddin != null)
                lastaddin.OnBalloonTipClicked(sender, e);
        }

        public TabControl Tab
        {
            get { return tabControl; }
        }

        public Menu MenuAddins
        {
            get { return mnuAddins; }
        }
    }
}